package com.isn.examenes.service;

import java.util.List;

import com.isn.examenes.entity.OrdenDeExamenes;
import com.isn.examenes.jpa.generarOrdenDeExamenJPA;

public class generarOrdenDeExamenServiceImpl implements generarOrdenDeExamenService {
	
	generarOrdenDeExamenJPA dao = new generarOrdenDeExamenJPA();
	generarOrdenDeExamenService ordenExamenService = new generarOrdenDeExamenServiceImpl();

	@Override
	public OrdenDeExamenes obtenerExamen(String estadoOe) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<OrdenDeExamenes> filtroEstado() throws Exception {

		dao.createEM();
		List<OrdenDeExamenes> filtroExamen = dao.ordenDeExamenes();
		dao.releaseEM();
		
		return filtroExamen;
	}

	@Override
	public void actualizar(OrdenDeExamenes ordenDeExamenes) {
		dao.createEM();
		dao.beginTransaction();
		try {
			dao.actualizar(ordenDeExamenes);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dao.endTransaction();
		
	}

	@Override
	public void eliminar(Integer codigo) throws Exception {
		dao.createEM();
		dao.beginTransaction();
		dao.eliminar(codigo);
		dao.endTransaction();
		
	}

	@Override
	public void registrar(OrdenDeExamenes ordenDeExamenes) {
		dao.createEM();
		dao.beginTransaction();
		try {
			dao.registrar(ordenDeExamenes);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ordenDeExamenes.setEstadoOe("PENDIENTE");				
		dao.endTransaction();
		
	}

	
	/*public OrdenDeExamenes obtenerExamen(String estadoOe) {
		
		dao.createEM();
		OrdenDeExamenes ordenDeExamenes = dao.obtenerExamen(estadoOe);
		
		
		return null;
	}*/
	
	

}
